export default {
  title: '热力图相关',
  data() {
    return {
      iconImg: ''
    }
  },
  methods: {
    /**
     * 添加热力图
     * @param lists
     * @param options
     */
    addHeatMap(lists = [], options) {
      let layerId = options.layerId || 'heatmapLayer'
      let mapLayer = this.gisIns.getLayer(layerId)
      if (!mapLayer) {
        // 创建一个热力图图层
        mapLayer = this.gisIns.createHeatmapLayer(layerId, {
          zIndex: 108,
          // gradient: ['#1D97FA', '#FF7800', '#FF0000']
        })
        if (options.hidden) {
          mapLayer.setVisible(false);
        }
      }
      let layerSource = mapLayer.getSource()
      let features = lists.map((item, index) => {
        return this.gisIns.createPoint(item.lng, item.lat)
      })
      // 清空该图层点位
      if (options.clear) {
        layerSource.clear()
      }
      this.gisIns.addIconArrFeatures(mapLayer, features, !!options.clear)
    },
  }
}
